package net.alche.fa.core.doing.invoker;
import net.alche.fa.core.doing.FaAnnoDoing;
import net.alche.fa.core.model.FaValue;
import java.util.List;
import net.alche.fa.core.FaException;

// FaObjInvoker
@FaAnnoDoing
public class FaObjInvoker extends AbstractObjectInvoker {

  public FaObjInvoker() {}

  // 是否为此对象
  public boolean matched(FaValue objVal, Object obj, String methodName, List<FaValue> params) {
    if ("equals".equals(methodName)) {
      return true;
    }
    return false;
  }

  // 调用
  public FaValue invoke(FaValue objVal, Object obj, String methodName, List<FaValue> params) throws FaException {
    FaValue first = params.get(0);
    if (first.isNull()) {
      return new FaValue(false);
    }
    return new FaValue(obj.equals(first.getValue()));
  }
}